package com.example.pet;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import com.example.pet.adapter.HomeViewPageAdapter;
import com.example.pet.fragment.ContentFragment;
import com.example.pet.fragment.Myself_fragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class login extends AppCompatActivity {

    private ViewPager2 viewPager2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_login_xd);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });


//
        viewPager2 = findViewById(R.id.main_vp2);
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(ContentFragment.newInstance());
        fragmentList.add(Myself_fragment.newInstance());
        HomeViewPageAdapter homeViewPageAdapter = new HomeViewPageAdapter(getSupportFragmentManager(), getLifecycle(), fragmentList);
        viewPager2.setAdapter(homeViewPageAdapter);

        viewPager2.setUserInputEnabled(false);

        BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);


        bottomNavigationView.setOnNavigationItemSelectedListener(item -> {
            // 当用户首次点击菜单项时调用
            int itemId = item.getItemId();
            if (itemId == R.id.main_home) {
                viewPager2.setCurrentItem(0, false);
                return true;
            } else if (itemId == R.id.main_me) {
                viewPager2.setCurrentItem(1, false);
                return true;
            }
            // 处理其他菜单项
            return false;
        });
    }
}
